home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7168 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: rcp6.elan.af.mil!rscernix!danpop
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Tradition or what?
  5. Date: 15 Feb 96 00:56:08 GMT
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <danpop.824345768@rscernix>
  8. References: <1996Feb13.115611.73989@cc.usu.edu>
  9. NNTP-Posting-Host: ues5.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11.  
  12. In <1996Feb13.115611.73989@cc.usu.edu> erik@cc.usu.edu (Erik van Renselaar) writes:
  13.  
  14. >Can anyone tell me what the use is of returning
  15. >the same value for the function and one of the
  16. >output parameters, like it is done in strcpy?
  17.  
  18. To be able to write obfuscated code like this:
  19.  
  20. strcat(strcpy(buff, "foo"), "bar");
  21.  
  22. >Why return a string for the function if the 
  23. >result is in its first parameter as well?
  24.  
  25. Apart from the above, there is no sensible answer.  Returning a pointer
  26. to the terminating null of the destination string would have been 
  27. considerably more useful.
  28.  
  29. >Is this just tradition or is it actually useful
  30. >for anything?
  31.  
  32. Since no sane person would use the return value of strcpy like I showed
  33. above, it's just tradition.
  34.  
  35. Dan
  36. --
  37. Dan Pop
  38. CERN, CN Division
  39. Email: danpop@mail.cern.ch 
  40. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  41.